// import { request } from "@/utils/request";
import { request } from "../../utils/http";

export const serviceApi = {
  /**
   * @description 查询当前医生的居民服务信息
   */
  getNowDrServiceInfo: (
    data: { doctorId: string; limit: string },
    config: any = {}
  ) => {
    return request.post<ServiceItemType[]>(
      "/api/getServiceDetailByDoctorId",
      data,
      config
    );
  },
  /**
   * @description (特详细)根据医生id和居民id查询指定状态的服务服务包信息
   * @param   residentId   居民id
   * @param    doctorId    当前登录医生id
   */

  getCurrentResidentInfo: (residentId: string, doctorId: string) => {
    return request.post("/api/getServiceDetailByResidentId", {
      residentId: residentId,
      doctorId: doctorId,
    });
  },
  /***
   * @description 更新居民的服务订单的服务信息
   * @param   orderId   服务服务包id
   * @param   status    想要更改成啥种状态
   * @param   status    状态，待审核为0，待支付为1，已驳回为2，生效中为3，已过期为4，默认0
   */
  updateServiceStatusById: (
    orderId: string,
    status: string,
    checkerId: string = ""
  ) => {
    return request.post("/api/updateStatusByServiceDetailId", {
      id: orderId,
      status: status,
      checkerId: checkerId,
    });
  },
  /***
   * @description 根据居民查询服务信息
   * @param   residentId   服务服务包id
   */
  getServiceDetail: (params: { residentId: string }, config: any = {}) => {
    return request.post("/api/getServiceDetailByResidentId", params, config);
  },
  /**
   * @description 根据服务详情id查询服务信息
   * @param {Object} data
   * @param data.id  服务详情id
   */
  getDetailByServiceId: (data: { id: string }) => {
    return request.post("/api/getServiceDetailById", data);
  },
};

/**
 * @description 服务服务包返回类型
 */
export interface ServiceItemType {
  id: string;
  number: string;
  residentId: string;
  organId: string;
  teamId: string;
  doctorId: string;
  serviceId: string;
  serviceItemId: string;
  address: number;
  appointmentTime: string;
  notes: string;
  submissionTime: string;
  status: number;
  score: number;
  auditTime: string;
  checkerId: string;
  finishTime: string;
  flag: number;
  resident: Resident;
  service: Service;
  serviceItem: ServiceItem;
}

interface Resident {
  id: string;
  number: string;
  userId: string;
  name: string;
  picture: string;
  IDCard: string;
  tel: string;
  address: string;
  district: string;
  gender: number;
  birthday: string;
  residenceId: string;
  nativePlace: string;
  residenceAddress: string;
  nationId: string;
  educationId: string;
  maritalStatusId: string;
  career: string;
  workUnit: string;
  emergencyContact: string;
  emergencyNumber: string;
  expenseTypeId: string;
  designatedMedicalUnits: string;
  origin: string;
  status: number;
  flag: number;
  createTime: string;
}

interface Service {
  id: string;
  name: string;
  typeId: string;
  price: number;
  targetAudience: string;
  period: number;
  renewal: number;
  picture: string;
  description: string;
  serviceDetail: string;
  flag: number;
}

interface ServiceItem {
  id: string;
  name: string;
  count: number;
  type: number;
  price: number;
  description: string;
  flag: number;
}
